import React, { memo, useCallback, useMemo } from "react"
import IconData from "@/icons/iconfont.json"
import { firstUpperCase } from "./util"
import "./style/index.css"
/**
 * 图标
 * @param {object} props
 * @param {object} [props.style] 样式
 * @param {string} [props.className] 类名
 * @param {boolean} [props.spin=false] 是否旋转
 * @returns {React.ReactNode}
 */
const Icon = memo((props) => {
    const { unicode, style = {}, className = "", spin = false } = props
    const content = String.fromCharCode(parseInt(unicode, 16))

    const render = () => {
        return <span className={`iconfont ${spin ? "rotate" : ""} ${className}`} style={style}>{content}</span>
    }
    return render()
})
const iconMap = IconData.glyphs.reduce((prev, item) => {
    const name = item.name.split("-").reduce((prev, cur) => prev + firstUpperCase(cur), "")
    return {
        ...prev,
        ["Icon" + name]: (props) => useMemo(() => <Icon {...props} unicode={item.unicode} />, [item.unicode])
    }
}, {})

export const IconAdd = iconMap.IconAdd
export const IconHistoryFilling = iconMap.IconHistoryFilling
export const IconFilterFilling = iconMap.IconFilterFilling
export const IconFileCommonFilling = iconMap.IconFileCommonFilling
export const IconNewsFilling = iconMap.IconNewsFilling
export const IconEditFilling = iconMap.IconEditFilling
export const IconFullscreenExpandFilling = iconMap.IconFullscreenExpandFilling
export const IconSmileFilling = iconMap.IconSmileFilling
export const IconRiseFilling = iconMap.IconRiseFilling
export const IconPictureFilling = iconMap.IconPictureFilling
export const IconNotificationFilling = iconMap.IconNotificationFilling
export const IconUserFilling = iconMap.IconUserFilling
export const IconSettingFilling = iconMap.IconSettingFilling
export const IconSwitchFilling = iconMap.IconSwitchFilling
export const IconWorkFilling = iconMap.IconWorkFilling
export const IconTaskFilling = iconMap.IconTaskFilling
export const IconSuccessFilling = iconMap.IconSuccessFilling
export const IconWarningFilling = iconMap.IconWarningFilling
export const IconFolderFilling = iconMap.IconFolderFilling
export const IconMapFilling = iconMap.IconMapFilling
export const IconPromptFilling = iconMap.IconPromptFilling
export const IconMehFilling = iconMap.IconMehFilling
export const IconCryFilling = iconMap.IconCryFilling
export const IconTopFilling = iconMap.IconTopFilling
export const IconHomeFilling = iconMap.IconHomeFilling
export const IconSorting = iconMap.IconSorting
export const IconPin = iconMap.IconPin
export const IconSave = iconMap.IconSave
export const IconSearch = iconMap.IconSearch
export const IconShare = iconMap.IconShare
export const IconScanning = iconMap.IconScanning
export const IconSecurity = iconMap.IconSecurity
export const IconSignOut = iconMap.IconSignOut
export const IconSelect = iconMap.IconSelect
export const IconStop = iconMap.IconStop
export const IconSuccess = iconMap.IconSuccess
export const IconSmile = iconMap.IconSmile
export const IconSwitch = iconMap.IconSwitch
export const IconSetting = iconMap.IconSetting
export const IconSurvey = iconMap.IconSurvey
export const IconTask = iconMap.IconTask
export const IconSkip = iconMap.IconSkip
export const IconText = iconMap.IconText
export const IconTime = iconMap.IconTime
export const IconTelephoneOut = iconMap.IconTelephoneOut
export const IconToggleLeft = iconMap.IconToggleLeft
export const IconToggleRight = iconMap.IconToggleRight
export const IconTelephone = iconMap.IconTelephone
export const IconTop = iconMap.IconTop
export const IconUnlock = iconMap.IconUnlock
export const IconUser = iconMap.IconUser
export const IconUpload = iconMap.IconUpload
export const IconWork = iconMap.IconWork
export const IconTraining = iconMap.IconTraining
export const IconWarning = iconMap.IconWarning
export const IconZoomIn = iconMap.IconZoomIn
export const IconZoomOut = iconMap.IconZoomOut
export const IconAddBold = iconMap.IconAddBold
export const IconArrowLeftBold = iconMap.IconArrowLeftBold
export const IconArrowUpBold = iconMap.IconArrowUpBold
export const IconCloseBold = iconMap.IconCloseBold
export const IconArrowDownBold = iconMap.IconArrowDownBold
export const IconMinusBold = iconMap.IconMinusBold
export const IconArrowRightBold = iconMap.IconArrowRightBold
export const IconSelectBold = iconMap.IconSelectBold
export const IconArrowUpFilling = iconMap.IconArrowUpFilling
export const IconArrowDownFilling = iconMap.IconArrowDownFilling
export const IconArrowLeftFilling = iconMap.IconArrowLeftFilling
export const IconArrowRightFilling = iconMap.IconArrowRightFilling
export const IconCapsUnlockFilling = iconMap.IconCapsUnlockFilling
export const IconCommentFilling = iconMap.IconCommentFilling
export const IconCheckItemFilling = iconMap.IconCheckItemFilling
export const IconClockFilling = iconMap.IconClockFilling
export const IconDeleteFilling = iconMap.IconDeleteFilling
export const IconDeclineFilling = iconMap.IconDeclineFilling
export const IconDynamicFilling = iconMap.IconDynamicFilling
export const IconIntermediateFilling = iconMap.IconIntermediateFilling
export const IconFavoriteFilling = iconMap.IconFavoriteFilling
export const IconLayoutFilling = iconMap.IconLayoutFilling
export const IconHelpFilling = iconMap.IconHelpFilling
export const IconRunIn = iconMap.IconRunIn
export const IconColumn3 = iconMap.IconColumn3
export const IconColumn4 = iconMap.IconColumn4
export const IconAddCircle = iconMap.IconAddCircle
export const IconAdjust = iconMap.IconAdjust
export const IconArrowUpCircle = iconMap.IconArrowUpCircle
export const IconArrowRightCircle = iconMap.IconArrowRightCircle
export const IconArrowDown = iconMap.IconArrowDown
export const IconAshbin = iconMap.IconAshbin
export const IconArrowRight = iconMap.IconArrowRight
export const IconBrowse = iconMap.IconBrowse
export const IconBottom = iconMap.IconBottom
export const IconBack = iconMap.IconBack
export const IconBad = iconMap.IconBad
export const IconArrowDoubleLeft = iconMap.IconArrowDoubleLeft
export const IconArrowLeftCircle = iconMap.IconArrowLeftCircle
export const IconArrowDoubleRight = iconMap.IconArrowDoubleRight
export const IconCapsLock = iconMap.IconCapsLock
export const IconCamera = iconMap.IconCamera
export const IconChartBar = iconMap.IconChartBar
export const IconAttachment = iconMap.IconAttachment
export const IconCode = iconMap.IconCode
export const IconClose = iconMap.IconClose
export const IconCheckItem = iconMap.IconCheckItem
export const IconCalendar = iconMap.IconCalendar
export const IconComment = iconMap.IconComment
export const IconColumnVertical = iconMap.IconColumnVertical
export const IconColumnHorizontal = iconMap.IconColumnHorizontal
export const IconComplete = iconMap.IconComplete
export const IconChartPie = iconMap.IconChartPie
export const IconCry = iconMap.IconCry
export const IconCustomerService = iconMap.IconCustomerService
export const IconDelete = iconMap.IconDelete
export const IconDirectionDown = iconMap.IconDirectionDown
export const IconCopy = iconMap.IconCopy
export const IconCut = iconMap.IconCut
export const IconDataView = iconMap.IconDataView
export const IconDirectionDownCircle = iconMap.IconDirectionDownCircle
export const IconDirectionRight = iconMap.IconDirectionRight
export const IconDirectionUp = iconMap.IconDirectionUp
export const IconDiscount = iconMap.IconDiscount
export const IconDirectionLeft = iconMap.IconDirectionLeft
export const IconDownload = iconMap.IconDownload
export const IconElectronics = iconMap.IconElectronics
export const IconDrag = iconMap.IconDrag
export const IconElipsis = iconMap.IconElipsis
export const IconExport = iconMap.IconExport
export const IconExplain = iconMap.IconExplain
export const IconEdit = iconMap.IconEdit
export const IconEyeClose = iconMap.IconEyeClose
export const IconEmail = iconMap.IconEmail
export const IconError = iconMap.IconError
export const IconFavorite = iconMap.IconFavorite
export const IconFileCommon = iconMap.IconFileCommon
export const IconFileDelete = iconMap.IconFileDelete
export const IconFileAdd = iconMap.IconFileAdd
export const IconFilm = iconMap.IconFilm
export const IconFabulous = iconMap.IconFabulous
export const IconFile = iconMap.IconFile
export const IconFolderClose = iconMap.IconFolderClose
export const IconFilter = iconMap.IconFilter
export const IconGood = iconMap.IconGood
export const IconHide = iconMap.IconHide
export const IconHome = iconMap.IconHome
export const IconHistory = iconMap.IconHistory
export const IconFileOpen = iconMap.IconFileOpen
export const IconForward = iconMap.IconForward
export const IconImport = iconMap.IconImport
export const IconImageText = iconMap.IconImageText
export const IconKeyboard26 = iconMap.IconKeyboard26
export const IconKeyboard9 = iconMap.IconKeyboard9
export const IconLink = iconMap.IconLink
export const IconLayout = iconMap.IconLayout
export const IconFullscreenShrink = iconMap.IconFullscreenShrink
export const IconLayers = iconMap.IconLayers
export const IconLock = iconMap.IconLock
export const IconFullscreenExpand = iconMap.IconFullscreenExpand
export const IconMap = iconMap.IconMap
export const IconMeh = iconMap.IconMeh
export const IconMenu = iconMap.IconMenu
export const IconLoading = iconMap.IconLoading
export const IconHelp = iconMap.IconHelp
export const IconMinusCircle = iconMap.IconMinusCircle
export const IconModular = iconMap.IconModular
export const IconNotification = iconMap.IconNotification
export const IconMic = iconMap.IconMic
export const IconMore = iconMap.IconMore
export const IconPad = iconMap.IconPad
export const IconOperation = iconMap.IconOperation
export const IconPlay = iconMap.IconPlay
export const IconPrint = iconMap.IconPrint
export const IconMobilePhone = iconMap.IconMobilePhone
export const IconMinus = iconMap.IconMinus
export const IconNavigation = iconMap.IconNavigation
export const IconPdf = iconMap.IconPdf
export const IconPrompt = iconMap.IconPrompt
export const IconMove = iconMap.IconMove
export const IconRefresh = iconMap.IconRefresh
export const IconRunUp = iconMap.IconRunUp
export const IconPicture = iconMap.IconPicture


export default iconMap